<?php
/**
 * Created by PhpStorm.
 * User: 宋春宝
 * Date: 2018/11/13
 * Time: 14:41
 */

namespace app\wchat\controller;


class Trackre extends Common
{
    public function index(){
        $info = db('dispatch_flow')->where('id',input('id'))->find();
        return $this->fetch('index',['info'=>$info]);
    }
    public function reupload(){

        $id = request()->param('id');
        $did = request()->param('did');

        if(empty($id)) return json(['code'=>0,'msg'=>'参数错误，请返回重新提交']);
        $args = [];
        $files = request()->param('files');
        if(count($files)>0)
            foreach($files as $file){
                $info = base64_image_content($file,APP_PATH .'/uploads/arga/'.$did);
                if($info){
                    $args[] = '/uploads/arga/'.$did.'/'.$info;
                }else{
                    return json(['code'=>0,'msg'=>'文件上传失败']);
                }
            }
        else
            return json(['code'=>0,'msg'=>'没有提交文件信息']);

        $ns = '';
        foreach ($args as $v){
            $ns .= $v.';';
        }

        $row = db('dispatch_flow')->where('id',$id)->update(['attach'=>$ns]);
        if($row){

            return json(['code'=>1,'msg'=>'信息提交成功']);
        }

        return json(['code'=>0,'msg'=>'信息提交失败']);
    }
}